<!DOCTYPE html>
<html>
<head>
{{template "common_header.html" .}}
</head>
<body>
<div class="x-body">
    <form class="layui-form" method="post" onsubmit="return false;" id="doc-update-admin-form">
        <input type="hidden" name="adminid" value="{{.adminUser.id}}" />
        <div class="layui-form-item">
            <label class="layui-form-label">账号</label>
            <div class="layui-input-block">
                <input type="text" name="account" required  lay-verify="required" placeholder="输入账号" autocomplete="off" class="layui-input" value="{{.adminUser.account}}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-block">
                <input type="password" name="password" placeholder="输入密码,密码长度不能小于6位" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">姓名</label>
            <div class="layui-input-block">
                <input type="text" name="name" required  lay-verify="required" placeholder="输入姓名" autocomplete="off" class="layui-input" value="{{.adminUser.name}}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手机</label>
            <div class="layui-input-block">
                <input type="text" name="phone" required  lay-verify="required" placeholder="输入手机号码" autocomplete="off" class="layui-input" value="{{.adminUser.phone}}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">权限</label>
            <div class="layui-input-block">
                <input type="radio" name="is_super" value="0" title="普通账号" {{if eq .adminUser.is_super 0}}checked{{end}}>
                <input type="radio" name="is_super" value="1" title="超级管理员" {{if eq .adminUser.is_super 1}}checked{{end}}>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="0" title="开启" {{if eq .adminUser.status 0}}checked{{end}}>
                <input type="radio" name="status" value="1" title="禁用" {{if eq .adminUser.status 1}}checked{{end}}>
            </div>
        </div>
        <div class="layui-form-item" style="margin-top:50px;">
            <button class="layui-btn layui-btn-normal" style="width:100%;" id="submit-btn">保存</button>
        </div>
    </form>
</div>
{{template "common_js.html" .}}
<script>
    layui.use('element', function(){
        var element = layui.element;
    });

    $(function(){
        $("#submit-btn").click(function () {
            var data = $("#doc-update-admin-form").serialize();
            var url = "/doUpdateAdmin";
            $.post(url, data, function (resp) {
                if(resp.en == 200) {
                    layer.msg(resp.em);
                    setTimeout(function(){
                        window.location.reload();
                    },1000);
                } else {
                    layer.msg(resp.em);
                }
            });
        });
    });
</script>
</body>
</html>